<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>档案管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/dist/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/static/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/static/dist/css/skins/all-skins.min.css">
    <link rel="stylesheet" href="/static/css/bootstrap-treeview.css">
    <link rel="stylesheet" href="/static/css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="/static/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="/static/layer/theme/default/layer.css">
    <link rel="stylesheet" href="/static/css/fileinput.min.css">
    <link rel="stylesheet" href="/static/css/fileinput-rtl.min.css">
    <link rel="stylesheet" href="/static/webCss/fglr.css?v=shujubuwqd12138">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/static/plugins/ie9/html5shiv.min.js"></script>
    <script src="/static/plugins/ie9/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue"  style="font-size: medium">
        <div class="content row" id="lxgl" style="padding-top: 0px!important;">
            <div class="col-xs-12 row">
                <div class="row text" style="margin-top: 20px;border-bottom: 1px solid #E8E8E8;margin-left: 20px">
                    <div class="col-xs-offset-4 col-xs-1" style="margin-top: -7px;">
                        <label class="activeTab" @click="fglrBtn" id="fglr">法规录入</label>
                    </div>
                    <div class="col-xs-offset-1 col-xs-1" style="margin-top: -7px;">
                        <label class="inactiveTab" @click="hybzlrBtn" id="hybzlr">行业标准录入</label>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-offset-3 col-xs-3 win" v-show="fglrShow">
                    <div class="row" style="border-bottom: 1px solid #DADCE0;">
                        <label style="padding: 10px;padding-top: 20px;font-family: PingFang SC">录入详情</label>
                    </div>
                    <div class="col-xs-12">
                        <form id="fglrForm"  enctype="multipart/form-data" style="margin-top: 20px;">
                            <div class="row">
                                <div class="form-group col-xs-6">
                                    <label >批准时间</label>
                                    <input v-model="falr.pzsj" name="pzsj" type="text" class="form-control input-sm" id="fgpzsj" @change="pzsjChange">
                                    <small style="color: #22d043">批准时间格式为xxxx-xx-xx</small>
                                </div>
                                <div class="form-group col-xs-6">
                                    <label >生效时间</label>
                                    <input v-model="falr.sxsj" name="sxsj" type="text" class="form-control input-sm" id="fgsxsj" @change="pzsjChange">
                                    <small style="color: #22d043">生效时间格式为xxxx-xx-xx</small>
                                </div>
                                <div class="form-group col-xs-6">
                                    <label>批准单位</label>
                                    <input v-model="falr.pzdw" name="pzdw" type="text" class="form-control input-sm">
                                </div>
                                <div class="form-group col-xs-12">
                                    <label>上传法规文件</label>
                                    <input ref="fileUpload" id="inputFile" class="file" type="file" data-show-preview="false"
                                           data-show-upload="false" name="files" accept="application/pdf" data-show-caption="true">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="text-center" style="padding-top: 428px;">
                        <button @click.prevent="mySubmit" type="submit" class="btn btn-primary" style="background-color: #2C72E8">提交法规文件</button>
                    </div>
                </div>
                <div class="col-xs-offset-3 col-xs-3 win" v-show="hybzlrShow">
                    <div class="row" style="border-bottom: 1px solid #DADCE0;">
                        <label style="padding: 10px;padding-top: 20px;font-family: PingFang SC">录入详情</label>
                    </div>
                    <div class="col-xs-12">
                        <form id="hybzlrForm"  enctype="multipart/form-data" style="margin-top: 20px;">
                            <div class="row">
                                <div class="form-group col-xs-6">
                                    <label >批准时间</label>
                                    <input v-model="hybzlr.pzsj" name="pzsj" type="text" class="form-control input-sm" id="hypzsj">
                                    <small style="color: #22d043">批准时间格式为xxxx-xx-xx</small>
                                </div>
                                <div class="form-group col-xs-6">
                                    <label >生效时间</label>
                                    <input v-model="hybzlr.sxsj" name="sxsj" type="text" class="form-control input-sm" id="hysxsj">
                                    <small style="color: #22d043">生效时间格式为xxxx-xx-xx</small>
                                </div>
                                <div class="form-group col-xs-6">
                                    <label>批准单位</label>
                                    <input v-model="hybzlr.pzdw" name="pzdw" type="text" class="form-control input-sm">
                                </div>
                                <div class="form-group col-xs-12">
                                    <label>上传行业标准</label>
                                    <input ref="fileUpload2" class="file" type="file" data-show-preview="false"
                                    data-show-upload="false" name="files" accept="application/pdf" data-show-caption="true">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="text-center" style="padding-top: 428px;">
                        <button @click.prevent="mySubmit2" type="submit" class="btn btn-primary" style="background-color: #2C72E8">提交行业标准</button>
                    </div>
                </div>
            </div>
        </div>

<script src="/static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- Slimscroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/static/plugins/fastclick/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/app.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/static/dist/js/demo.js"></script>
<!--tabs-->
<script src="/static/dist/js/app_iframe.js"></script>
<script src="/static/js/bootstrap-treeview.js"></script>
<script src="/static/js/bootstrapValidator.min.js"></script>
<script src="/static/plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="/static/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="/static/js/vue.js"></script>
<script src="/static/js/vue-resource.min.js"></script>
        <script src="/static/layer/layer.js"></script>
<script src="/static/js/myJs.js?v=shujubuwqd12138"></script>
<script src="/static/js/fileinput.min.js"></script>
        <script src="/static/js/zh.js"></script>
        <script src="/static/js/newJs.js?v=shujubuwqd12138"></script>

<script type="text/javascript">
    newCss("/static/webCss/fglr.css");
    $(document).off('change','#fgpzsj').on('change','#fgpzsj',function(){
        var cwTime = document.getElementById('fgpzsj').value;
        if(cwTime !== ""&&$("#fgpzsj").val() !== null){
            var cwFormat = cwTime.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
            if(cwFormat == null){
                cxAlert("时间格式不正确，请输入正确的时间格式如XXXX-XX-XX");
                document.getElementById('fgpzsj').value = "";
            }else{
                // console.log($("#cwrq").val());
                // //vue.$data.wsxx.cwrq = $(" #cwrq ").val();
                // document.getElementById("cwrqTitle").style.color = "#00a65a";
                // document.getElementById("cwrq").style.borderColor = "#00a65a";
                // document.getElementById("cwrq").style.backgroundColor = "#E8F0FE";
                // vue.$data.isNull = false;
            }
        }else{
            // document.getElementById("cwrqTitle").style.color = "#dd4b39";
            // document.getElementById("cwrq").style.borderColor = "#dd4b39";
            // document.getElementById("cwrq").style.backgroundColor = "#FFFFFF";
            // vue.$data.isNull = true;

        }
    });
    $(document).off('change','#fgsxsj').on('change','#fgsxsj',function(){
        var cwTime = document.getElementById('fgsxsj').value;
        if(cwTime !== ""&&$("#fgsxsj").val() !== null){
            var cwFormat = cwTime.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
            if(cwFormat == null){
                cxAlert("时间格式不正确，请输入正确的时间格式如XXXX-XX-XX");
                document.getElementById('fgsxsj').value = "";
            }else{
                // console.log($("#cwrq").val());
                // //vue.$data.wsxx.cwrq = $(" #cwrq ").val();
                // document.getElementById("cwrqTitle").style.color = "#00a65a";
                // document.getElementById("cwrq").style.borderColor = "#00a65a";
                // document.getElementById("cwrq").style.backgroundColor = "#E8F0FE";
                // vue.$data.isNull = false;
            }
        }else{
            // document.getElementById("cwrqTitle").style.color = "#dd4b39";
            // document.getElementById("cwrq").style.borderColor = "#dd4b39";
            // document.getElementById("cwrq").style.backgroundColor = "#FFFFFF";
            // vue.$data.isNull = true;

        }
    });
    $(document).off('change','#hypzsj').on('change','#hypzsj',function(){
        var cwTime2 = $("#hypzsj").val();
        if(cwTime2 !== ""&&cwTime2 !== null){
            var cwFormat2 = cwTime2.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
            if(cwFormat2 == null){
                cxAlert("时间格式不正确，请输入正确的时间格式如XXXX-XX-XX");
                document.getElementById('hypzsj').value = "";
            }else{
                //console.log($("#cwrq").val());
                //vue.$data.wsxx.cwrq = $(" #cwrq ").val();
                // document.getElementById("gdsjTitle").style.color = "#00a65a";
                // document.getElementById("gdsj").style.borderColor = "#00a65a";
                // document.getElementById("gdsj").style.backgroundColor = "#E8F0FE";
                // vue.$data.isNull2 = false;
            }
        }else{
            // document.getElementById("gdsjTitle").style.color = "#dd4b39";
            // document.getElementById("gdsj").style.borderColor = "#dd4b39";
            // document.getElementById("gdsj").style.backgroundColor = "#FFFFFF";
            // vue.$data.isNull2 = true;

        }
    });
    $(document).off('change','#hysxsj').on('change','#hysxsj',function(){
        var cwTime2 = $("#hysxsj").val();
        if(cwTime2 !== ""&&cwTime2 !== null){
            var cwFormat2 = cwTime2.match(/^(\d{4})(-)(\d{2})(-)(\d{2})$/);
            if(cwFormat2 == null){
                cxAlert("时间格式不正确，请输入正确的时间格式如XXXX-XX-XX");
                document.getElementById('hysxsj').value = "";
            }else{
                //console.log($("#cwrq").val());
                //vue.$data.wsxx.cwrq = $(" #cwrq ").val();
                // document.getElementById("gdsjTitle").style.color = "#00a65a";
                // document.getElementById("gdsj").style.borderColor = "#00a65a";
                // document.getElementById("gdsj").style.backgroundColor = "#E8F0FE";
                // vue.$data.isNull2 = false;
            }
        }else{
            // document.getElementById("gdsjTitle").style.color = "#dd4b39";
            // document.getElementById("gdsj").style.borderColor = "#dd4b39";
            // document.getElementById("gdsj").style.backgroundColor = "#FFFFFF";
            // vue.$data.isNull2 = true;

        }
    });
    $(function(){
        $('.mydatepicker').datepicker({
            language: 'zh-CN',
            autoclose: true,
            format: 'yyyy-mm-dd',
            todayHighlight: true
        });
    });

    //initFileInput();
    function initFileInput() {
        $(".file").fileinput({
            language: 'zh',
        })
    }
        var vue = new Vue({
        el:'#lxgl',
        data:{
            hybzlrShow:false,
            fglrShow:true,
            falr:{
                id:null,
                name:null,
                pzsj:null,
                sxsj:null,
                pzdw:null,
                uploadtime:null,
                uplodusername:null,
                uploduserid:null,
                bh:null,
            },
            hybzlr:{
                id:null,
                name:null,
                pzsj:null,
                sxsj:null,
                pzdw:null,
                uploadtime:null,
                uplodusername:null,
                uploduserid:null,
                bh:null,
        }
        },
        methods:{
            pzsjChange:function(){
                this.falr.pzsj = $('#fgpzsj').val();
                this.hybzlr.pzsj = $('#hypzsj').val();
            },
            fglrBtn:function(){
                this.fglrShow = true;
                this.hybzlrShow = false;
                document.getElementById('fglr').className = 'activeTab';
                document.getElementById('hybzlr').className = 'inactiveTab';
            },
            hybzlrBtn:function(){
                this.fglrShow = false;
                this.hybzlrShow = true;
                document.getElementById('fglr').className = 'inactiveTab';
                document.getElementById('hybzlr').className = 'activeTab';
            },
            mySubmit:function () {
                this.falr.pzsj = $('#fgpzsj').val();
                this.falr.sxsj = $('#fgsxsj').val();
                // var time = new Date(this.falr.pzsj);
                // this.falr.pzsj = time.getFullYear();
                var fileUpload = this.$refs.fileUpload;

                var file = fileUpload.files;
                var data = new FormData();
                for (var i = 0; i < file.length; i++) {
                    data.append('multipartFile', file[i])
                }
                //this.falr.multipartFile = file;
                //data.append('fg', this.falr)
                //Object.keys(this.falr).forEach(key => (data.append(key,this.falr[key])));

                var myMsg = cxLoad("上传中");
                this.$http.post('/fglr/api/addFg?id='+this.falr.id+'&name='+this.falr.name+'&pzsj='+this.falr.pzsj+'&pzdw='+this.falr.pzdw+'&uploadtime='+this.falr.sxsj,data).then(function (result) {
                    var data = result.body;
                    layer.close(myMsg);
                    if (data.code == 200) {
                        cxAlertOk("上传成功");
                        $(".fileinput-remove-button").click();
                    } else {
                        cxAlert(data.mess);
                    }
                });
            },
            mySubmit2:function () {
                var fileUpload2 = this.$refs.fileUpload2;
                var file = fileUpload2.files;
                var data2 = new FormData();
                for (var i = 0; i < file.length; i++) {
                    data2.append('multipartFile', file[i])
                }
                //console.log(data);
                //data2.append('',this.hybzlr)
                var myMsg = cxLoad("上传中");
                this.$http.post('/hxbz/api/addHxbz?id='+this.hybzlr.id+'&name='+this.hybzlr.name+'&pzsj='+this.hybzlr.pzsj+'&pzdw='+this.hybzlr.pzdw+'&uploadtime='+this.hybzlr.sxsj, data2).then(function (result) {
                    var data = result.body;
                    layer.close(myMsg);
                    if (data.code == 200) {
                        cxAlertOk("上传成功");
                        $(".fileinput-remove-button").click();
                    } else {
                        cxAlert(data.mess);
                    }
                });
            }
        },
        mounted:function () {
            var that = this;
            this.$http.get('/getUser').then( function (result) {
                var data = result.body;
                if(data.code == 200){
                    that.falr.id = data.data.id;
                    that.falr.name = data.data.name;
                    that.hybzlr.id = data.data.id;
                    that.hybzlr.name = data.data.name;
                }
            });
        }
    });
</script>

</body>
</html>
